Algorithmic Trading Model for Moving Average Crossover Mean-Reversion Strategy with Volume Indicator Using Python

David Lowe

December 23, 2020

NOTE: This script is for learning purposes only and does not constitute a recommendation for buying or selling any stock mentioned in this script.

SUMMARY: This project aims to construct and test an algorithmic trading model and document the end-to-end steps using a template. We will test trading models with the naive momentum strategy.

INTRODUCTION: This algorithmic trading model examines a simplistic naive momentum strategy in comparison to a buy-and-hold approach. The plan goes long (buys) on the stock when the daily closing price improves from the previous day for a pre-defined consecutive number of days. Conversely, we will exit the position when the daily price declines for the same successive number of days. Furthermore, we will use the trading volumes to confirm the buy and sell signals by comparing them to the 10-day moving average.

ANALYSIS: From this iteration, we analyzed the stock prices for Johnson and Johnson (JNJ) between January 1, 2019, and December 11, 2020. The trading model produced a profit of 48.42 dollars per share. The buy-and-hold approach yielded a gain of 23.40 dollars per share.

CONCLUSION: For the stock of AAPL during the modeling time frame, the trading strategy did not produce a better return than the buy-and-hold approach. We should consider modeling this stock further by experimenting with more variations of the strategy.

Dataset ML Model: Time series analysis with numerical attributes

Dataset Used: Quandl

An algorithmic trading modeling project generally can be broken down into about five major tasks:

  1. Prepare Environment
  2. Acquire and Pre-Process Data
  3. Implement and Train Models
  4. Back-test Models
  5. Evaluate Strategy Performance

Task 1 - Prepare Environment

In [1]:
# # Install the necessary packages for Colab
# !pip install python-dotenv PyMySQL
In [2]:
# # Retrieve the GPU information from Colab
# gpu_info = !nvidia-smi
# gpu_info = '\n'.join(gpu_info)
# if gpu_info.find('failed') >= 0:
#     print('Select the Runtime → "Change runtime type" menu to enable a GPU accelerator, ')
#     print('and then re-execute this cell.')
# else:
#     print(gpu_info)
In [3]:
# # Retrieve the memory configuration from Colab
# from psutil import virtual_memory
# ram_gb = virtual_memory().total / 1e9
# print('Your runtime has {:.1f} gigabytes of available RAM\n'.format(ram_gb))
#
# if ram_gb < 20:
#     print('To enable a high-RAM runtime, select the Runtime → "Change runtime type"')
#     print('menu, and then select High-RAM in the Runtime shape dropdown. Then, ')
#     print('re-execute this cell.')
# else:
#     print('You are using a high-RAM runtime!')
In [4]:
# # Retrieve the CPU information
# ncpu = !nproc
# print("The number of available CPUs is:", ncpu[0])

1.a) Load libraries and modules

In [5]:
import pandas as pd
import matplotlib.pyplot as plt
import os
import sys
from datetime import date, datetime, timedelta
import requests
import json
from dotenv import load_dotenv
# import pandas_datareader.data as pdr

# Begin the timer for the script processing
startTimeScript = datetime.now()

1.b) Set up the controlling parameters and functions¶

In [6]:
# Specify the key modeling parameters below
STOCK_SYMBOL = 'JNJ'
INITIAL_CAPITAL = 0

# Specify the moving average parameters for the trading strategy
FAST_MA_MIN = 10
FAST_MA_MAX = 30
SLOW_MA_MIN = 20
SLOW_MA_MAX = 60
VOL_MA_MIN = 10
VOL_MA_MAX = 30
MA_INCREMENT = 5
VOL_INCREMENT = 5
MA_GAP = 5

# The number of extra days of data we need for calculating moving averages (usually equals to the largest value of slow MA)
EXTRA_DAYS = SLOW_MA_MAX

MODEL_START_DATE = date(2019, 1, 1)
print("Starting date for the model:", MODEL_START_DATE)

MODEL_END_DATE = datetime.now().date()
# MODEL_END_DATE = date(2020, 11, 20)
print("Ending date for the model:", MODEL_END_DATE)

# data_start_date = MODEL_START_DATE
data_start_date = MODEL_START_DATE - timedelta(days=int(EXTRA_DAYS * 1.5)) # Need more pricing data to calculate moving averages
print("First date of data we need for modeling:", data_start_date)

data_end_date = MODEL_END_DATE
print("Last date of data we need for modeling:", data_end_date)
Starting date for the model: 2019-01-01
Ending date for the model: 2020-12-13
First date of data we need for modeling: 2018-10-03
Last date of data we need for modeling: 2020-12-13
In [7]:
# Specify the script running parameters below

# Set Pandas options
pd.set_option("display.max_rows", None)
pd.set_option("display.max_columns", None)
pd.set_option("display.width", 160)

# Configure the plotting style
plt.style.use('seaborn')

# Set up the verbose flag to print detailed messages for debugging (setting True will activate!)
verbose_signals = False
verbose_models = False
verbose_graphs = True
verbose_portfolios = False
verbose_transactions = False
verbose_positions = True
In [8]:
# Set up the parent directory location for loading the dotenv files

# # Mount Google Drive locally for storing files
# from google.colab import drive
# drive.mount('/content/gdrive')
# gdrivePrefix = '/content/gdrive/My Drive/Colab_Downloads/'
# env_path = '/content/gdrive/My Drive/Colab Notebooks/'
# dotenv_path = env_path + "python_script.env"
# load_dotenv(dotenv_path=dotenv_path)

# Set up access to the dotenv file on local PC
# env_path = "/Users/david/PycharmProjects/"
# dotenv_path = env_path + "python_script.env"
# load_dotenv(dotenv_path=dotenv_path)

Task 2 - Acquire and Pre-Process Data

In [9]:
# Set up the data service provider and data acquisition parameters
data_service = 'Quandl'

# Check and see whether the API key is available
api_key = os.environ.get('QUANDL_API')
if api_key is None: sys.exit("API key for Quandl not available. Script Processing Aborted!!!")

start_date_string = data_start_date.strftime('%Y-%m-%d')
end_date_string = data_end_date.strftime('%Y-%m-%d')
api_url = "https://www.quandl.com/api/v3/datatables/SHARADAR/SEP.json?date.gte=%s&date.lte=%s&ticker=%s&api_key=%s" % (start_date_string, end_date_string, STOCK_SYMBOL, api_key)
response = requests.get(api_url)
resp_dict = json.loads(response.text)
stock_rawdata = pd.DataFrame(resp_dict['datatable']['data'])
print(len(stock_rawdata), 'data points retrieved from the API call.')
553 data points retrieved from the API call.
In [10]:
stock_rawdata.columns = ['ticker', 'date', 'open', 'high', 'low', 'close', 'volume', 'dividend', 'closeunadj', 'lastupdated']
# stock_rawdata.set_index('date', inplace=True)
stock_rawdata.index = pd.to_datetime(stock_rawdata.date)
stock_pricing = stock_rawdata.sort_index(ascending=True)
print(stock_pricing.head())
print()
print(stock_pricing.tail())
           ticker        date    open    high     low   close     volume  dividend  closeunadj lastupdated
date                                                                                                      
2018-10-03    JNJ  2018-10-03  140.54  141.27  138.88  139.03  5411809.0       0.0      139.03  2020-05-01
2018-10-04    JNJ  2018-10-04  138.55  139.53  137.32  139.35  4627338.0       0.0      139.35  2020-05-01
2018-10-05    JNJ  2018-10-05  139.80  140.25  138.56  139.10  4308820.0       0.0      139.10  2020-05-01
2018-10-08    JNJ  2018-10-08  138.90  139.68  138.62  139.39  5174106.0       0.0      139.39  2020-05-01
2018-10-09    JNJ  2018-10-09  138.74  139.62  137.81  139.20  4475282.0       0.0      139.20  2020-05-01

           ticker        date    open    high      low   close     volume  dividend  closeunadj lastupdated
date                                                                                                       
2020-12-07    JNJ  2020-12-07  149.35  149.91  148.510  148.97  6632769.0       0.0      148.97  2020-12-07
2020-12-08    JNJ  2020-12-08  150.00  152.14  149.550  151.55  8336413.0       0.0      151.55  2020-12-08
2020-12-09    JNJ  2020-12-09  152.83  153.50  151.755  153.10  8432131.0       0.0      153.10  2020-12-09
2020-12-10    JNJ  2020-12-10  152.82  152.98  151.680  152.25  7390688.0       0.0      152.25  2020-12-10
2020-12-11    JNJ  2020-12-11  151.53  153.41  151.230  152.95  5971806.0       0.0      152.95  2020-12-11
In [11]:
# Set up the standard column name for modeling
# Column names may be data-provider specific!
MODEL_TEMPLATE = stock_pricing.loc[:, ['open','close','volume']]
MODEL_TEMPLATE.rename(columns={'open': 'open_price', 'close': 'close_price', 'volume': 'trading_volume'}, inplace=True)
plot_title = 'Historical Stock Close Price for ' + STOCK_SYMBOL + ' from ' + data_service
MODEL_TEMPLATE['close_price'].plot(figsize=(16,9), title=plot_title)
plt.show()

Task 3 - Implement and Train Models

In [12]:
# Define the function that will generate the indicators and trading signals
def populate_signals(fast_ma=FAST_MA_MIN, slow_ma=SLOW_MA_MIN, vol_ma=VOL_MA_MIN):

    trade_model = MODEL_TEMPLATE.copy()
    trade_model['fast_ma'] = trade_model['close_price'].rolling(fast_ma).mean()
    trade_model['slow_ma'] = trade_model['close_price'].rolling(slow_ma).mean()
    trade_model['volume_ma'] = trade_model['trading_volume'].rolling(vol_ma).mean()
    # trade_model['fast_ma'] = trade_model['close_price'].ewm(span=fast_ma).mean()
    # trade_model['slow_ma'] = trade_model['close_price'].ewm(span=slow_ma).mean()
    # trade_model['volume_ma'] = trade_model['trading_volume'].ewm(span=vol_ma).mean()
    trade_model['ma_change'] = trade_model['fast_ma'] - trade_model['slow_ma']
    trade_model['momentum_streak'] = 0
    trade_model['trade_signal'] = 0
    trade_model['entry_exit'] = 0
    prior_signal = 0
    prior_ownership = False
    currently_own = False

    # Truncate the model to the required starting and ending dates
    trade_model = trade_model[MODEL_START_DATE:MODEL_END_DATE]

    for k in range(len(trade_model)):
        current_signal = 0
        crossover = trade_model.at[trade_model.index[k],'ma_change']
        trade_volume = trade_model.at[trade_model.index[k],'trading_volume']
        average_volume = trade_model.at[trade_model.index[k],'volume_ma']
        trade_model.at[trade_model.index[k],'entry_exit'] = prior_signal
        if prior_signal == 1:
            currently_own = True
        elif  prior_signal == -1:
            currently_own = False
        else:
            currently_own = prior_ownership

        if (crossover < 0) and (trade_volume > average_volume) and (not currently_own):
            current_signal = 1  # trade_signal = 1 means we should buy
            currently_own = True
        elif (crossover > 0) and (trade_volume > average_volume) and currently_own:
            current_signal = -1  # trade_signal = -1 means we should sell
            currently_own = False
        trade_model.at[trade_model.index[k],'trade_signal'] = current_signal
        prior_signal = current_signal
        prior_ownership = currently_own

    # Exiting the position on the last day of modeling period
    if currently_own:
        trade_model.at[trade_model.index[-1],'entry_exit'] = -1
    if verbose_signals: print(trade_model, '\n')
    return trade_model
In [13]:
# Build the collection of trading models by iterating through the parameters
trading_model_collection = {}
serial_no = 0
for model_fastma in range(FAST_MA_MIN, FAST_MA_MAX+1, MA_INCREMENT):
    for model_slowma in range(SLOW_MA_MIN, SLOW_MA_MAX+1, MA_INCREMENT):
        for model_vol in range(VOL_MA_MIN, VOL_MA_MAX+1, VOL_INCREMENT):
            if (model_slowma - model_fastma) < MA_GAP: break
            serial_no += 1
            model_tag = 'Model_' + str(serial_no).zfill(3) + '_FASTMA_' + str(model_fastma).zfill(2) + '_SLOWMA_' + str(model_slowma).zfill(2) + '_VOL_' + str(model_vol).zfill(2)
            if verbose_signals: print('Processing model:', model_tag)
            trading_model = populate_signals(model_fastma, model_slowma, model_vol)
            trading_model_collection[model_tag] = trading_model.copy()
print(len(trading_model_collection), 'trading models generated!')
195 trading models generated!
In [14]:
# List the entry/exit points for each model
def list_model_entry_exit(trade_model):
    print(trade_model[(trade_model['trade_signal'] != 0) | (trade_model['entry_exit'] != 0)])
In [15]:
if verbose_models:
    for model_name in trading_model_collection:
        print('List the signal changes and entry/exit points for model:', model_name)
        list_model_entry_exit(trading_model_collection[model_name])
        print()
In [16]:
def draw_model_graph(trade_model, mdl_name=STOCK_SYMBOL):
    graph_data = trade_model.copy()
    title_string = 'Moving Average Crossover Momentum Trading Model for ' + mdl_name
    fig = plt.figure(figsize=(16,9))
    ylabel = STOCK_SYMBOL + ' price in $'
    ax1 = fig.add_subplot(111, ylabel=ylabel, title=title_string)
    graph_data['close_price'].plot(ax=ax1, color='g')
    ax1.plot(graph_data.loc[graph_data.entry_exit == 1].index, graph_data.close_price[graph_data.entry_exit == 1], '^', markersize=7, color='k',label='buy')
    ax1.plot(graph_data.loc[graph_data.entry_exit == -1].index, graph_data.close_price[graph_data.entry_exit == -1], 'v', markersize=7, color='k',label='sell')
    plt.legend(loc='upper left')
    plt.show()
In [17]:
if verbose_graphs:
    for model_name in trading_model_collection:
        draw_model_graph(trading_model_collection[model_name], model_name)

Task 4 - Back-test Models

In [18]:
def generate_trading_portfolios(trade_model):
    # Construct a portfolio to track the transactions and returns
    portfolio = pd.DataFrame(index=trade_model.index, columns=['trade_action', 'qty_onhand', 'cost_basis', 'sold_transaction', 'gain_loss', 'cash_onhand', 'position_value', 'total_position', 'accum_return'])
    portfolio.iloc[0]['trade_action'] = 0
    portfolio.iloc[0]['qty_onhand'] = 0
    portfolio.iloc[0]['cost_basis'] = 0.00
    portfolio.iloc[0]['sold_transaction'] = 0.00
    portfolio.iloc[0]['gain_loss'] = 0.00
    portfolio.iloc[0]['cash_onhand'] = INITIAL_CAPITAL
    portfolio.iloc[0]['position_value'] = 0.00
    portfolio.iloc[0]['total_position'] = INITIAL_CAPITAL
    portfolio.iloc[0]['accum_return'] = portfolio.iloc[0]['total_position'] - INITIAL_CAPITAL
    recent_cost = 0

    # The conditional parameters below determine how the trading strategy will be carried out
    for i in range(1, len(portfolio)):
        if (trade_model.iloc[i]['entry_exit'] == 1) and (portfolio.iloc[i-1]['qty_onhand'] == 0):
            portfolio.iloc[i]['trade_action'] = 1
            portfolio.iloc[i]['qty_onhand'] = portfolio.iloc[i-1]['qty_onhand'] + portfolio.iloc[i]['trade_action']
            portfolio.iloc[i]['cost_basis'] = trade_model.iloc[i]['open_price'] * portfolio.iloc[i]['trade_action']
            portfolio.iloc[i]['sold_transaction'] = 0.00
            portfolio.iloc[i]['gain_loss'] = 0.00
            portfolio.iloc[i]['cash_onhand'] = portfolio.iloc[i-1]['cash_onhand'] - portfolio.iloc[i]['cost_basis']
            recent_cost = trade_model.iloc[i]['open_price'] * portfolio.iloc[i]['trade_action']
            if verbose_portfolios: print('BOUGHT QTY:', portfolio.iloc[i]['trade_action'], 'on', portfolio.index[i], 'at the price of', trade_model.iloc[i]['open_price'])
        elif (trade_model.iloc[i]['entry_exit'] == -1) and (portfolio.iloc[i-1]['qty_onhand'] > 0):
            portfolio.iloc[i]['trade_action'] = -1
            portfolio.iloc[i]['qty_onhand'] = portfolio.iloc[i-1]['qty_onhand'] + portfolio.iloc[i]['trade_action']
            portfolio.iloc[i]['cost_basis'] = 0.00
            portfolio.iloc[i]['sold_transaction'] = trade_model.iloc[i]['open_price'] * portfolio.iloc[i]['trade_action'] * -1
            portfolio.iloc[i]['gain_loss'] = (recent_cost + (trade_model.iloc[i]['open_price'] * portfolio.iloc[i]['trade_action'])) * -1
            portfolio.iloc[i]['cash_onhand'] = portfolio.iloc[i-1]['cash_onhand'] + portfolio.iloc[i]['sold_transaction']
            recent_cost = 0.00
            if verbose_portfolios: print('SOLD QTY:', portfolio.iloc[i]['trade_action'], 'on', portfolio.index[i], 'at the price of', trade_model.iloc[i]['open_price'])
        else:
            portfolio.iloc[i]['trade_action'] = 0
            portfolio.iloc[i]['qty_onhand'] = portfolio.iloc[i-1]['qty_onhand']
            portfolio.iloc[i]['cost_basis'] = portfolio.iloc[i-1]['cost_basis']
            portfolio.iloc[i]['sold_transaction'] = 0.00
            portfolio.iloc[i]['gain_loss'] = 0.00
            portfolio.iloc[i]['cash_onhand'] = portfolio.iloc[i-1]['cash_onhand']
        portfolio.iloc[i]['position_value'] = trade_model.iloc[i]['close_price'] * portfolio.iloc[i]['qty_onhand']
        portfolio.iloc[i]['total_position'] = portfolio.iloc[i]['cash_onhand'] + portfolio.iloc[i]['position_value']
        portfolio.iloc[i]['accum_return'] = portfolio.iloc[i]['total_position'] - INITIAL_CAPITAL

    if verbose_portfolios: print('\n', portfolio, '\n')
    return portfolio
In [19]:
def calculate_positions_and_performance(trade_model):
    trade_positions = generate_trading_portfolios(trade_model)
    trade_transactions = trade_positions[trade_positions['trade_action'] != 0]
    if verbose_transactions: print(trade_transactions)
    if verbose_transactions:
        if trade_transactions.iloc[-1]['trade_action'] == 1:
            print('The current status of the model is:', 'Holding a position since', trade_transactions.index.tolist()[-1].date(), '\n')
        else:
            print('The current status of the model is:', 'Waiting to enter since', trade_transactions.index.tolist()[-1].date(), '\n')
    return trade_positions
In [20]:
# Convert trading models into positions and calculate profit and loss
# Initialize a dictionary for tracking positions for all models
model_positions_colletion={}

for model_name in trading_model_collection:
    if verbose_portfolios: print('Processing the positions for model:', model_name)
    model_positions_colletion[model_name] = calculate_positions_and_performance(trading_model_collection[model_name])
print(len(model_positions_colletion), 'sets of model positions generated.')
195 sets of model positions generated.
In [21]:
# Initialize a dataframe for storing the model's profit and loss
model_performance_summary = pd.DataFrame(columns=['Model_name','Return_value','Return_percentage'])
for model_name in model_positions_colletion:
    if verbose_positions: print('Processing positions for model:', model_name)
    if verbose_positions: print('Accumulated profit/loss for one share of stock with initial capital of $%.0f at the end of modeling period: $%.2f' % (INITIAL_CAPITAL, model_positions_colletion[model_name].accum_return[-1]))
    if INITIAL_CAPITAL != 0:
        return_percentage = model_positions_colletion[model_name].accum_return[-1] / INITIAL_CAPITAL * 100
        if verbose_positions: print('Accumulated return percentage based on the initial capital investment: %.2f%%' % return_percentage)
    else:
        return_percentage = None
    if verbose_positions: print()
    model_performance_summary = model_performance_summary.append({'Model_name': model_name, 'Return_value': model_positions_colletion[model_name].accum_return[-1], 'Return_percentage': return_percentage}, ignore_index=True)
    model_performance_summary.sort_values(by=['Return_value'], inplace=True, ascending=False)

print(len(model_performance_summary), 'profit/loss summaries generated.\n')
print('The top ten model\'s performance summary:')
print(model_performance_summary.head(10))
Processing positions for model: Model_001_FASTMA_10_SLOWMA_20_VOL_10
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $14.23

Processing positions for model: Model_002_FASTMA_10_SLOWMA_20_VOL_15
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $19.05

Processing positions for model: Model_003_FASTMA_10_SLOWMA_20_VOL_20
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $21.99

Processing positions for model: Model_004_FASTMA_10_SLOWMA_20_VOL_25
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $23.52

Processing positions for model: Model_005_FASTMA_10_SLOWMA_20_VOL_30
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $26.78

Processing positions for model: Model_006_FASTMA_10_SLOWMA_25_VOL_10
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $10.77

Processing positions for model: Model_007_FASTMA_10_SLOWMA_25_VOL_15
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $12.73

Processing positions for model: Model_008_FASTMA_10_SLOWMA_25_VOL_20
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $20.32

Processing positions for model: Model_009_FASTMA_10_SLOWMA_25_VOL_25
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $17.02

Processing positions for model: Model_010_FASTMA_10_SLOWMA_25_VOL_30
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $12.74

Processing positions for model: Model_011_FASTMA_10_SLOWMA_30_VOL_10
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $21.07

Processing positions for model: Model_012_FASTMA_10_SLOWMA_30_VOL_15
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $21.00

Processing positions for model: Model_013_FASTMA_10_SLOWMA_30_VOL_20
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $28.73

Processing positions for model: Model_014_FASTMA_10_SLOWMA_30_VOL_25
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $19.91

Processing positions for model: Model_015_FASTMA_10_SLOWMA_30_VOL_30
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $14.99

Processing positions for model: Model_016_FASTMA_10_SLOWMA_35_VOL_10
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $20.77

Processing positions for model: Model_017_FASTMA_10_SLOWMA_35_VOL_15
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $20.36

Processing positions for model: Model_018_FASTMA_10_SLOWMA_35_VOL_20
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $25.20

Processing positions for model: Model_019_FASTMA_10_SLOWMA_35_VOL_25
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $16.38

Processing positions for model: Model_020_FASTMA_10_SLOWMA_35_VOL_30
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $15.11

Processing positions for model: Model_021_FASTMA_10_SLOWMA_40_VOL_10
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $16.48

Processing positions for model: Model_022_FASTMA_10_SLOWMA_40_VOL_15
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $16.41

Processing positions for model: Model_023_FASTMA_10_SLOWMA_40_VOL_20
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $25.87

Processing positions for model: Model_024_FASTMA_10_SLOWMA_40_VOL_25
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $14.13

Processing positions for model: Model_025_FASTMA_10_SLOWMA_40_VOL_30
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $14.13

Processing positions for model: Model_026_FASTMA_10_SLOWMA_45_VOL_10
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $23.91

Processing positions for model: Model_027_FASTMA_10_SLOWMA_45_VOL_15
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $23.84

Processing positions for model: Model_028_FASTMA_10_SLOWMA_45_VOL_20
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $33.30

Processing positions for model: Model_029_FASTMA_10_SLOWMA_45_VOL_25
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $21.56

Processing positions for model: Model_030_FASTMA_10_SLOWMA_45_VOL_30
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $17.72

Processing positions for model: Model_031_FASTMA_10_SLOWMA_50_VOL_10
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $33.36

Processing positions for model: Model_032_FASTMA_10_SLOWMA_50_VOL_15
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $34.60

Processing positions for model: Model_033_FASTMA_10_SLOWMA_50_VOL_20
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $39.99

Processing positions for model: Model_034_FASTMA_10_SLOWMA_50_VOL_25
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $28.25

Processing positions for model: Model_035_FASTMA_10_SLOWMA_50_VOL_30
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $24.41

Processing positions for model: Model_036_FASTMA_10_SLOWMA_55_VOL_10
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $30.53

Processing positions for model: Model_037_FASTMA_10_SLOWMA_55_VOL_15
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $32.40

Processing positions for model: Model_038_FASTMA_10_SLOWMA_55_VOL_20
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $32.61

Processing positions for model: Model_039_FASTMA_10_SLOWMA_55_VOL_25
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $26.79

Processing positions for model: Model_040_FASTMA_10_SLOWMA_55_VOL_30
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $26.79

Processing positions for model: Model_041_FASTMA_10_SLOWMA_60_VOL_10
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $35.57

Processing positions for model: Model_042_FASTMA_10_SLOWMA_60_VOL_15
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $38.44

Processing positions for model: Model_043_FASTMA_10_SLOWMA_60_VOL_20
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $39.61

Processing positions for model: Model_044_FASTMA_10_SLOWMA_60_VOL_25
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $33.79

Processing positions for model: Model_045_FASTMA_10_SLOWMA_60_VOL_30
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $31.84

Processing positions for model: Model_046_FASTMA_15_SLOWMA_20_VOL_10
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $12.23

Processing positions for model: Model_047_FASTMA_15_SLOWMA_20_VOL_15
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $6.37

Processing positions for model: Model_048_FASTMA_15_SLOWMA_20_VOL_20
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $13.44

Processing positions for model: Model_049_FASTMA_15_SLOWMA_20_VOL_25
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $17.46

Processing positions for model: Model_050_FASTMA_15_SLOWMA_20_VOL_30
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $16.56

Processing positions for model: Model_051_FASTMA_15_SLOWMA_25_VOL_10
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $34.39

Processing positions for model: Model_052_FASTMA_15_SLOWMA_25_VOL_15
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $29.86

Processing positions for model: Model_053_FASTMA_15_SLOWMA_25_VOL_20
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $34.58

Processing positions for model: Model_054_FASTMA_15_SLOWMA_25_VOL_25
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $31.28

Processing positions for model: Model_055_FASTMA_15_SLOWMA_25_VOL_30
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $27.00

Processing positions for model: Model_056_FASTMA_15_SLOWMA_30_VOL_10
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $30.93

Processing positions for model: Model_057_FASTMA_15_SLOWMA_30_VOL_15
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $30.39

Processing positions for model: Model_058_FASTMA_15_SLOWMA_30_VOL_20
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $33.35

Processing positions for model: Model_059_FASTMA_15_SLOWMA_30_VOL_25
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $27.02

Processing positions for model: Model_060_FASTMA_15_SLOWMA_30_VOL_30
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $25.75

Processing positions for model: Model_061_FASTMA_15_SLOWMA_35_VOL_10
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $35.30

Processing positions for model: Model_062_FASTMA_15_SLOWMA_35_VOL_15
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $37.19

Processing positions for model: Model_063_FASTMA_15_SLOWMA_35_VOL_20
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $36.88

Processing positions for model: Model_064_FASTMA_15_SLOWMA_35_VOL_25
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $27.88

Processing positions for model: Model_065_FASTMA_15_SLOWMA_35_VOL_30
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $26.61

Processing positions for model: Model_066_FASTMA_15_SLOWMA_40_VOL_10
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $40.06

Processing positions for model: Model_067_FASTMA_15_SLOWMA_40_VOL_15
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $38.27

Processing positions for model: Model_068_FASTMA_15_SLOWMA_40_VOL_20
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $37.82

Processing positions for model: Model_069_FASTMA_15_SLOWMA_40_VOL_25
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $28.82

Processing positions for model: Model_070_FASTMA_15_SLOWMA_40_VOL_30
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $28.82

Processing positions for model: Model_071_FASTMA_15_SLOWMA_45_VOL_10
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $34.63

Processing positions for model: Model_072_FASTMA_15_SLOWMA_45_VOL_15
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $34.71

Processing positions for model: Model_073_FASTMA_15_SLOWMA_45_VOL_20
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $34.26

Processing positions for model: Model_074_FASTMA_15_SLOWMA_45_VOL_25
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $28.26

Processing positions for model: Model_075_FASTMA_15_SLOWMA_45_VOL_30
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $28.26

Processing positions for model: Model_076_FASTMA_15_SLOWMA_50_VOL_10
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $30.62

Processing positions for model: Model_077_FASTMA_15_SLOWMA_50_VOL_15
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $34.19

Processing positions for model: Model_078_FASTMA_15_SLOWMA_50_VOL_20
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $32.56

Processing positions for model: Model_079_FASTMA_15_SLOWMA_50_VOL_25
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $29.48

Processing positions for model: Model_080_FASTMA_15_SLOWMA_50_VOL_30
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $29.48

Processing positions for model: Model_081_FASTMA_15_SLOWMA_55_VOL_10
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $31.70

Processing positions for model: Model_082_FASTMA_15_SLOWMA_55_VOL_15
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $36.43

Processing positions for model: Model_083_FASTMA_15_SLOWMA_55_VOL_20
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $34.80

Processing positions for model: Model_084_FASTMA_15_SLOWMA_55_VOL_25
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $28.98

Processing positions for model: Model_085_FASTMA_15_SLOWMA_55_VOL_30
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $27.55

Processing positions for model: Model_086_FASTMA_15_SLOWMA_60_VOL_10
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $37.11

Processing positions for model: Model_087_FASTMA_15_SLOWMA_60_VOL_15
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $37.40

Processing positions for model: Model_088_FASTMA_15_SLOWMA_60_VOL_20
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $35.77

Processing positions for model: Model_089_FASTMA_15_SLOWMA_60_VOL_25
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $29.95

Processing positions for model: Model_090_FASTMA_15_SLOWMA_60_VOL_30
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $28.00

Processing positions for model: Model_091_FASTMA_20_SLOWMA_25_VOL_10
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $44.09

Processing positions for model: Model_092_FASTMA_20_SLOWMA_25_VOL_15
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $42.28

Processing positions for model: Model_093_FASTMA_20_SLOWMA_25_VOL_20
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $43.74

Processing positions for model: Model_094_FASTMA_20_SLOWMA_25_VOL_25
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $39.90

Processing positions for model: Model_095_FASTMA_20_SLOWMA_25_VOL_30
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $34.35

Processing positions for model: Model_096_FASTMA_20_SLOWMA_30_VOL_10
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $48.42

Processing positions for model: Model_097_FASTMA_20_SLOWMA_30_VOL_15
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $44.58

Processing positions for model: Model_098_FASTMA_20_SLOWMA_30_VOL_20
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $43.77

Processing positions for model: Model_099_FASTMA_20_SLOWMA_30_VOL_25
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $36.78

Processing positions for model: Model_100_FASTMA_20_SLOWMA_30_VOL_30
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $35.51

Processing positions for model: Model_101_FASTMA_20_SLOWMA_35_VOL_10
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $36.44

Processing positions for model: Model_102_FASTMA_20_SLOWMA_35_VOL_15
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $46.74

Processing positions for model: Model_103_FASTMA_20_SLOWMA_35_VOL_20
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $47.23

Processing positions for model: Model_104_FASTMA_20_SLOWMA_35_VOL_25
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $34.58

Processing positions for model: Model_105_FASTMA_20_SLOWMA_35_VOL_30
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $33.31

Processing positions for model: Model_106_FASTMA_20_SLOWMA_40_VOL_10
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $31.45

Processing positions for model: Model_107_FASTMA_20_SLOWMA_40_VOL_15
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $28.55

Processing positions for model: Model_108_FASTMA_20_SLOWMA_40_VOL_20
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $36.47

Processing positions for model: Model_109_FASTMA_20_SLOWMA_40_VOL_25
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $25.85

Processing positions for model: Model_110_FASTMA_20_SLOWMA_40_VOL_30
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $23.90

Processing positions for model: Model_111_FASTMA_20_SLOWMA_45_VOL_10
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $33.49

Processing positions for model: Model_112_FASTMA_20_SLOWMA_45_VOL_15
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $25.28

Processing positions for model: Model_113_FASTMA_20_SLOWMA_45_VOL_20
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $35.85

Processing positions for model: Model_114_FASTMA_20_SLOWMA_45_VOL_25
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $30.03

Processing positions for model: Model_115_FASTMA_20_SLOWMA_45_VOL_30
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $23.29

Processing positions for model: Model_116_FASTMA_20_SLOWMA_50_VOL_10
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $31.76

Processing positions for model: Model_117_FASTMA_20_SLOWMA_50_VOL_15
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $32.42

Processing positions for model: Model_118_FASTMA_20_SLOWMA_50_VOL_20
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $35.86

Processing positions for model: Model_119_FASTMA_20_SLOWMA_50_VOL_25
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $30.04

Processing positions for model: Model_120_FASTMA_20_SLOWMA_50_VOL_30
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $28.09

Processing positions for model: Model_121_FASTMA_20_SLOWMA_55_VOL_10
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $29.81

Processing positions for model: Model_122_FASTMA_20_SLOWMA_55_VOL_15
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $36.40

Processing positions for model: Model_123_FASTMA_20_SLOWMA_55_VOL_20
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $43.67

Processing positions for model: Model_124_FASTMA_20_SLOWMA_55_VOL_25
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $35.82

Processing positions for model: Model_125_FASTMA_20_SLOWMA_55_VOL_30
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $29.08

Processing positions for model: Model_126_FASTMA_20_SLOWMA_60_VOL_10
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $31.54

Processing positions for model: Model_127_FASTMA_20_SLOWMA_60_VOL_15
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $40.28

Processing positions for model: Model_128_FASTMA_20_SLOWMA_60_VOL_20
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $46.77

Processing positions for model: Model_129_FASTMA_20_SLOWMA_60_VOL_25
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $38.92

Processing positions for model: Model_130_FASTMA_20_SLOWMA_60_VOL_30
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $34.13

Processing positions for model: Model_131_FASTMA_25_SLOWMA_30_VOL_10
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $33.86

Processing positions for model: Model_132_FASTMA_25_SLOWMA_30_VOL_15
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $37.05

Processing positions for model: Model_133_FASTMA_25_SLOWMA_30_VOL_20
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $35.90

Processing positions for model: Model_134_FASTMA_25_SLOWMA_30_VOL_25
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $28.45

Processing positions for model: Model_135_FASTMA_25_SLOWMA_30_VOL_30
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $22.26

Processing positions for model: Model_136_FASTMA_25_SLOWMA_35_VOL_10
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $31.90

Processing positions for model: Model_137_FASTMA_25_SLOWMA_35_VOL_15
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $39.65

Processing positions for model: Model_138_FASTMA_25_SLOWMA_35_VOL_20
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $45.15

Processing positions for model: Model_139_FASTMA_25_SLOWMA_35_VOL_25
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $30.26

Processing positions for model: Model_140_FASTMA_25_SLOWMA_35_VOL_30
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $28.31

Processing positions for model: Model_141_FASTMA_25_SLOWMA_40_VOL_10
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $23.63

Processing positions for model: Model_142_FASTMA_25_SLOWMA_40_VOL_15
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $21.00

Processing positions for model: Model_143_FASTMA_25_SLOWMA_40_VOL_20
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $23.00

Processing positions for model: Model_144_FASTMA_25_SLOWMA_40_VOL_25
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $14.26

Processing positions for model: Model_145_FASTMA_25_SLOWMA_40_VOL_30
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $16.95

Processing positions for model: Model_146_FASTMA_25_SLOWMA_45_VOL_10
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $17.03

Processing positions for model: Model_147_FASTMA_25_SLOWMA_45_VOL_15
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $20.04

Processing positions for model: Model_148_FASTMA_25_SLOWMA_45_VOL_20
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $19.90

Processing positions for model: Model_149_FASTMA_25_SLOWMA_45_VOL_25
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $14.08

Processing positions for model: Model_150_FASTMA_25_SLOWMA_45_VOL_30
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $16.77

Processing positions for model: Model_151_FASTMA_25_SLOWMA_50_VOL_10
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $21.10

Processing positions for model: Model_152_FASTMA_25_SLOWMA_50_VOL_15
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $24.19

Processing positions for model: Model_153_FASTMA_25_SLOWMA_50_VOL_20
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $26.67

Processing positions for model: Model_154_FASTMA_25_SLOWMA_50_VOL_25
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $20.85

Processing positions for model: Model_155_FASTMA_25_SLOWMA_50_VOL_30
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $23.54

Processing positions for model: Model_156_FASTMA_25_SLOWMA_55_VOL_10
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $26.88

Processing positions for model: Model_157_FASTMA_25_SLOWMA_55_VOL_15
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $21.64

Processing positions for model: Model_158_FASTMA_25_SLOWMA_55_VOL_20
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $24.12

Processing positions for model: Model_159_FASTMA_25_SLOWMA_55_VOL_25
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $18.30

Processing positions for model: Model_160_FASTMA_25_SLOWMA_55_VOL_30
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $20.99

Processing positions for model: Model_161_FASTMA_25_SLOWMA_60_VOL_10
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $43.53

Processing positions for model: Model_162_FASTMA_25_SLOWMA_60_VOL_15
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $27.51

Processing positions for model: Model_163_FASTMA_25_SLOWMA_60_VOL_20
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $29.21

Processing positions for model: Model_164_FASTMA_25_SLOWMA_60_VOL_25
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $23.39

Processing positions for model: Model_165_FASTMA_25_SLOWMA_60_VOL_30
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $26.08

Processing positions for model: Model_166_FASTMA_30_SLOWMA_35_VOL_10
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $18.12

Processing positions for model: Model_167_FASTMA_30_SLOWMA_35_VOL_15
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $22.84

Processing positions for model: Model_168_FASTMA_30_SLOWMA_35_VOL_20
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $24.59

Processing positions for model: Model_169_FASTMA_30_SLOWMA_35_VOL_25
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $13.36

Processing positions for model: Model_170_FASTMA_30_SLOWMA_35_VOL_30
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $19.33

Processing positions for model: Model_171_FASTMA_30_SLOWMA_40_VOL_10
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $20.40

Processing positions for model: Model_172_FASTMA_30_SLOWMA_40_VOL_15
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $8.14

Processing positions for model: Model_173_FASTMA_30_SLOWMA_40_VOL_20
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $16.23

Processing positions for model: Model_174_FASTMA_30_SLOWMA_40_VOL_25
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $7.49

Processing positions for model: Model_175_FASTMA_30_SLOWMA_40_VOL_30
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $7.49

Processing positions for model: Model_176_FASTMA_30_SLOWMA_45_VOL_10
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $32.06

Processing positions for model: Model_177_FASTMA_30_SLOWMA_45_VOL_15
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $12.86

Processing positions for model: Model_178_FASTMA_30_SLOWMA_45_VOL_20
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $19.60

Processing positions for model: Model_179_FASTMA_30_SLOWMA_45_VOL_25
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $13.78

Processing positions for model: Model_180_FASTMA_30_SLOWMA_45_VOL_30
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $13.78

Processing positions for model: Model_181_FASTMA_30_SLOWMA_50_VOL_10
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $38.20

Processing positions for model: Model_182_FASTMA_30_SLOWMA_50_VOL_15
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $33.40

Processing positions for model: Model_183_FASTMA_30_SLOWMA_50_VOL_20
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $34.92

Processing positions for model: Model_184_FASTMA_30_SLOWMA_50_VOL_25
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $29.10

Processing positions for model: Model_185_FASTMA_30_SLOWMA_50_VOL_30
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $30.29

Processing positions for model: Model_186_FASTMA_30_SLOWMA_55_VOL_10
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $38.65

Processing positions for model: Model_187_FASTMA_30_SLOWMA_55_VOL_15
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $38.47

Processing positions for model: Model_188_FASTMA_30_SLOWMA_55_VOL_20
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $40.17

Processing positions for model: Model_189_FASTMA_30_SLOWMA_55_VOL_25
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $34.35

Processing positions for model: Model_190_FASTMA_30_SLOWMA_55_VOL_30
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $34.35

Processing positions for model: Model_191_FASTMA_30_SLOWMA_60_VOL_10
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $41.21

Processing positions for model: Model_192_FASTMA_30_SLOWMA_60_VOL_15
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $45.76

Processing positions for model: Model_193_FASTMA_30_SLOWMA_60_VOL_20
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $45.25

Processing positions for model: Model_194_FASTMA_30_SLOWMA_60_VOL_25
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $39.43

Processing positions for model: Model_195_FASTMA_30_SLOWMA_60_VOL_30
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $39.43

195 profit/loss summaries generated.

The top ten model's performance summary:
                             Model_name  Return_value Return_percentage
0  Model_096_FASTMA_20_SLOWMA_30_VOL_10         48.42              None
1  Model_103_FASTMA_20_SLOWMA_35_VOL_20         47.23              None
2  Model_128_FASTMA_20_SLOWMA_60_VOL_20         46.77              None
3  Model_102_FASTMA_20_SLOWMA_35_VOL_15         46.74              None
4  Model_192_FASTMA_30_SLOWMA_60_VOL_15         45.76              None
5  Model_193_FASTMA_30_SLOWMA_60_VOL_20         45.25              None
6  Model_138_FASTMA_25_SLOWMA_35_VOL_20         45.15              None
7  Model_097_FASTMA_20_SLOWMA_30_VOL_15         44.58              None
8  Model_091_FASTMA_20_SLOWMA_25_VOL_10         44.09              None
9  Model_098_FASTMA_20_SLOWMA_30_VOL_20         43.77              None

Task 5 - Evaluate Strategy Performance

In [22]:
# Calculate the stock's performance for a buy-and-hold model
top_model_name = model_performance_summary.loc[0]['Model_name']
top_trading_model = trading_model_collection[top_model_name]
print('The entry point for the buy-and-hold model: $%.2f on %s' % (top_trading_model.iloc[0]['open_price'], top_trading_model.index[0].date()))
print('The exit point for the buy-and-hold model: $%.2f on %s' % (top_trading_model.iloc[-1]['open_price'], top_trading_model.index[-1].date()))
print('The performance of the buy-and-hold model: $%.2f' %(top_trading_model.iloc[-1]['open_price'] - top_trading_model.iloc[0]['open_price']))
print('The performance of the top trading model: $%.2f' %(model_performance_summary.iloc[0]['Return_value']))
The entry point for the buy-and-hold model: $128.13 on 2019-01-02
The exit point for the buy-and-hold model: $151.53 on 2020-12-11
The performance of the buy-and-hold model: $23.40
The performance of the top trading model: $48.42
In [23]:
top_model_positions = model_positions_colletion[top_model_name]
print(top_model_positions[top_model_positions['trade_action'] != 0])
           trade_action qty_onhand cost_basis sold_transaction gain_loss cash_onhand position_value total_position accum_return
date                                                                                                                           
2019-01-09            1          1     129.83                0         0     -129.83         128.93           -0.9         -0.9
2019-02-01           -1          0          0           134.02      4.19        4.19              0           4.19         4.19
2019-04-15            1          1        136                0         0     -131.81         136.52           4.71         4.71
2019-05-07           -1          0          0           140.82      4.82        9.01              0           9.01         9.01
2019-05-30            1          1     131.44                0         0     -122.43         132.11           9.68         9.68
2019-06-27           -1          0          0           142.23     10.79        19.8              0           19.8         19.8
2019-07-22            1          1        130                0         0      -110.2         128.64          18.44        18.44
2019-08-26           -1          0          0           127.42     -2.58       17.22              0          17.22        17.22
2019-08-27            1          1     129.88                0         0     -112.66         129.64          16.98        16.98
2019-10-01           -1          0          0           130.02      0.14       17.36              0          17.36        17.36
2019-11-14            1          1     131.03                0         0     -113.67         130.96          17.29        17.29
2019-11-21           -1          0          0           135.94      4.91       22.27              0          22.27        22.27
2020-03-02            1          1     134.78                0         0     -112.51         140.02          27.51        27.51
2020-04-21           -1          0          0           150.12     15.34       37.61              0          37.61        37.61
2020-05-27            1          1     144.32                0         0     -106.71         144.89          38.18        38.18
2020-07-31           -1          0          0           146.66      2.34       39.95              0          39.95        39.95
2020-08-24            1          1     152.74                0         0     -112.79         152.15          39.36        39.36
2020-08-27           -1          0          0           152.42     -0.32       39.63              0          39.63        39.63
2020-09-24            1          1     144.56                0         0     -104.93         144.67          39.74        39.74
2020-10-27           -1          0          0           143.74     -0.82       38.81              0          38.81        38.81
2020-10-30            1          1     136.68                0         0      -97.87         137.11          39.24        39.24
2020-12-01           -1          0          0           146.29      9.61       48.42              0          48.42        48.42
In [24]:
draw_model_graph(trading_model_collection[top_model_name], top_model_name)
In [25]:
print ('Total time for the script:',(datetime.now() - startTimeScript))
Total time for the script: 0:11:15.731229